import request from '@/store/request'

// 获取列表
export function roleList (page, size) {
  return request({
    url: 'security/role/page',
    method: 'post',
    dataType: 'josn',
    data: {
      page: page,
      size: size
    }
  })
}
// 新增角色
export function insert (form) {
  return request({
    url: 'security/role/insert',
    method: 'POST',
    dataType: 'josn',
    data: form
  })
}

// 查询角色对应的菜单
export function getMenuByRole (id) {
  return request({
    url: 'security/role/menu/page/' + id,
    method: 'get',
    dataType: 'josn'
  })
}

// 获取全部菜单
export function allMenu () {
  return request({
    url: 'security/menu/page',
    method: 'get',
    dataType: 'josn'
  })
}

// 增加角色菜单
export function menuAdd (roleId, objIds) {
  return request({
    url: 'security/role/menu/add',
    method: 'post',
    dataType: 'josn',
    data: {
      roleId: roleId,
      menuIds: objIds
    }
  })
}

// 判断角色编号是否存在
export function isExistCode (code) {
  return request({
    url: 'security/role/exist/' + code,
    method: 'get',
    dataType: 'josn'
  })
}

// 编辑角色
export function update (form) {
  return request({
    url: 'security/role/update',
    method: 'POST',
    dataType: 'josn',
    data: form
  })
}
